import requests

from crawler_core.exception.request_exec import RequestException


class RequestUtils:

    @staticmethod
    def get(url, param):
        try:
            response = requests.get(url=url, params=param)
            return response.json()
        except RequestException:
            return None

    @staticmethod
    def post(url, data):
        _headers = {"Content-Type": 'application/json;charset=UTF-8'}
        response = requests.post(url=url, json=data, headers=_headers)
        return response.json()
